package com.imooc.producer.f_code;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.nio.ByteBuffer;

/**
 * @author 折戟沉沙铁未销
 * @version V1.0
 * @date 2024/4/12-2024
 * @Description: 这里用一句话描述这个类的作用
 */
public class Producer1 {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("p_1");
        producer.setNamesrvAddr("139.129.91.21:9876");
        // ??? 干嘛用的？
        //producer.setUnitName("aaa");

        producer.setSendLatencyFaultEnable(true);
        producer.getProducerGroup();

        producer.setSendMsgTimeout(3000*10);
        producer.start();

        Message message = new Message("p_1_topic", "tag1", "key1", "111".getBytes());
        SendResult sendResult = producer.send(message);
        System.out.println(sendResult);

        //ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
        //byteBuffer.slice();

    }
}